package com.youyi.yyviewsdklibrary;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.lkx.liandianqinew.R;
import com.youyi.yyviewsdklibrary.Dialog.XPopup;
import com.youyi.yyviewsdklibrary.Dialog.core.XDialog;
import com.youyi.yyviewsdklibrary.Dialog.interfaces.OnViewBack;

public class LoadingDialog {
    private static XDialog mXDialog;

    public enum DialogType {
        FULL,
        CENTER
    }

    public static void show(Context context, DialogType dialogType, final boolean z) {
        hidden();
        XPopup.showDefineNoFalse(context, XPopup.DirecEnum.CENTER, z, dialogType.equals(DialogType.FULL) ? R.layout._yy_loading_dialog : R.layout._yy_loading_dialog02, new OnViewBack() {
            /* class com.youyi.yyviewsdklibrary.LoadingDialog.AnonymousClass1 */

            @Override // com.youyi.yyviewsdklibrary.Dialog.interfaces.OnViewBack
            public void result(XDialog xDialog, View view) {
                XDialog unused = LoadingDialog.mXDialog = xDialog;
                ((TextView) view.findViewById(R.id.id_text)).setVisibility(View.GONE);
                LoadingDialog.mXDialog.setCancelable(false);
                if (z) {
                    view.setOnClickListener(new View.OnClickListener() {
                        /* class com.youyi.yyviewsdklibrary.LoadingDialog.AnonymousClass1.AnonymousClass1 */

                        public void onClick(View view) {
                            LoadingDialog.hidden();
                        }
                    });
                }
            }
        });
    }

    public static void show(Context context, DialogType dialogType, final boolean z, final String str) {
        hidden();
        XPopup.showDefineNoFalse(context, XPopup.DirecEnum.CENTER, z, dialogType.equals(DialogType.FULL) ? R.layout._yy_loading_dialog : R.layout._yy_loading_dialog02, new OnViewBack() {
            /* class com.youyi.yyviewsdklibrary.LoadingDialog.AnonymousClass2 */

            @Override // com.youyi.yyviewsdklibrary.Dialog.interfaces.OnViewBack
            public void result(XDialog xDialog, View view) {
                XDialog unused = LoadingDialog.mXDialog = xDialog;
                TextView textView = (TextView) view.findViewById(R.id.id_text);
                if (!TextUtils.isEmpty(str)) {
                    textView.setVisibility(View.VISIBLE);
                    textView.setText(str);
                } else {
                    textView.setVisibility(View.GONE);
                }
                LoadingDialog.mXDialog.setCancelable(false);
                if (z) {
                    view.setOnClickListener(new View.OnClickListener() {
                        /* class com.youyi.yyviewsdklibrary.LoadingDialog.AnonymousClass2.AnonymousClass1 */

                        public void onClick(View view) {
                            LoadingDialog.hidden();
                        }
                    });
                }
            }
        });
    }

    public static void hidden() {
        try {
            XDialog xDialog = mXDialog;
            if (xDialog != null) {
                xDialog.dismiss();
                mXDialog = null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
